package cz.cvut.fel.gfupan.gui.action;

import cz.cvut.fel.gfupan.gui.component.AutoCompleteBox;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class AutoCompleteAction implements ActionListener {

    private AutoCompleteBox combo;

    public AutoCompleteAction(AutoCompleteBox root) {
        this.combo = root;
    }

    @Override
    public void actionPerformed(ActionEvent evt) {
        if (combo.getSelectedIndex() == -1) {
//WHY selection do not work without this line !!!
            combo.setSelectedItem(combo.getItemAt(0));
        }
    }
}